<?php
/**
 * Object Relational Persistence Mapping Class for table: sale_program_store
 *
 * @package	com.athena
 * @author	LHV
 */
class SaleProgramStore extends ORDataObject {

	/**#@+
	 * Fields of table: sale_program_store mapped to class members
	 */
	var $sale_program_store_id		= '';
	var $sale_program_id		= '';
	var $start_date		= '';
	var $end_date		= '';
	

	/**
	 * DB Table
	 */
	var $_table = 'sale_program_store';

	/**
	 * Primary Key
	 */
	var $_key = 'sale_program_store_id';
	
	/**
	 * Internal Name
	 */
	var $_internalName = 'SaleProgramStore';

	/**
	 * Handle instantiation
	 */
	function SaleProgramStore() {
		parent::ORDataObject();
	}


	/**#@+
	 * Field: start_date, time formatting
	 */
	function get_start_date() {
		return $this->_getDate('start_date');
	}
	function set_start_date($date) {
		$this->_setDate('start_date',$date);
	}
	/**#@-*/

	/**#@+
	 * Field: end_date, time formatting
	 */
	function get_end_date() {
		return $this->_getDate('end_date');
	}
	function set_end_date($date) {
		$this->_setDate('end_date',$date);
	}
	/**#@-*/

	function getProgramStoreOfSale($saleId) {		
		$sql = "select sale_program_store_id from $this->_table
			where sale_program_id = $saleId AND end_date >= NOW()";
		$res = $this->_execute($sql);
		if ($res && !$res->EOF) {
			return $res->fields['sale_program_store_id'];	
		}
		return false;		
	}
		
}
?>